package com.jnsw.testkotlin;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jnsw.testkotlin.adapter.MyRecyclerAdapter;
import com.jnsw.testkotlin.bean.User;

import java.util.ArrayList;
import java.util.List;

public class RecycleActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_recycle);


        RecyclerView myrecview = (RecyclerView) findViewById(R.id.myrecview);
        List<User>  users = new ArrayList<>();
        User user = new User();
        user.setName("user1");
        user.setAge(26);
        users.add(user);
        User user1 = new User();
        user1.setName("user11");
        user1.setAge(27);
        users.add(user1);
        users.add(user);
        users.add(user1);
        users.add(user);
        users.add(user1);
        users.add(user);
//        myrecview.setLayoutManager(new GridLayoutManager(this,2));//必须设置
        myrecview.setLayoutManager(new GridLayoutManager(this,2));//必须设置
        MyRecyclerAdapter adapter = new MyRecyclerAdapter(users);
        adapter.openLoadAnimation();
        myrecview.setAdapter(adapter);


    }
}
